import {
	notification,
	Modal
} from 'ant-design-vue';
const duration = 2;
const success = function(title, msg) {
	notification.success({
		message: title ? title : "success",
		duration: duration,
		description: msg ? msg : ""
	})
};
const error = function(title, msg) {
	notification.error({
		message: title ? title : "error",
		duration: duration,
		description: msg ? msg : ""
	})
};
const info = function(title, msg) {
	notification.info({
		message: title ? title : "this is a message",
		duration: duration,
		description: msg ? msg : ""
	})
};
const warning = function(title, msg) {
	notification.warning({
		message: title ? title : "this is a warning",
		duration: duration,
		description: msg ? msg : ""
	})
};
const confirm = function(data) {
	return new Promise((resolve, reject) =>{
		Modal.confirm({
			title: '提示',
			content: (data || {}).name!=null?`你真的要删除${data.name}吗？`:"你确定需要删除吗?",
			okText: "确定",
			keyboard: true,
			cancelText: "取消",
			onOk() {
				resolve();
			},
			onCancel() {
				reject();
			},
		})
	});
	
}
const show = function(msg) {
	return new Promise((resolve, reject) =>{
		Modal.confirm({
			title: '提示',
			content: msg,
			okText: "确定",
			keyboard: true,
			cancelText: "取消",
			onOk() {
				resolve();
			},
			onCancel() {
				reject();
			},
		})
	});
	
}
export default {
	success,
	error,
	info,
	warning,
	confirm,
	show
};
